# -*- autoconf -*-
# Process this file with autoconf to produce a configure script

AC_PREREQ(2.62)
AC_INIT([hegrid], [0.01], [basile.clout@unb.ca])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

# Check for a C compiler and awk
AC_PROG_CC
AC_PROG_AWK

# Check for other programs
AC_PATH_PROG(PERL, perl)
gl_PERL()

AM_PATH_PYTHON(,,[:])
AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])

dnl AC_CHECK_PROG(PYTHON, python, python, no)
dnl if test $PYTHON = "no"
dnl then
dnl	AC_WARN([Python not found on traditional paths!])
dnl fi

AC_PATH_PROG(NMAP, nmap, no)
if test $NMAP = "no"
then
	AC_WARN([Nmap not found on traditional paths!])
fi

AC_CHECK_PROG(IPERF, iperf, iperf, no)
if test $IPERF = "no"
then
	AC_WARN([Iperf not found on traditional paths!])
fi

AC_PATH_PROG(GNUPLOT, gnuplot, no)
if test $GNUPLOT = "no"
then
	AC_WARN([Gnuplot not found on traditional paths!])
fi

AC_PATH_PROG(SSH, ssh, no)
if test $SSH = "no"
then
	AC_WARN([SSH not found on traditional paths!])
fi

AC_PATH_PROG(GRAPHVIZ, neato, no)
if test $GRAPHVIZ = "no"
then
	AC_WARN([Graphviz (neato) not found on traditional paths!])
fi

dnl 64 bits?
dnl Not really good ...

dnl AC_CHECK_SIZEOF([long long int])
dnl if test "$SIZEOF_LONG" = "8";
dnl then
dnl	AC_DEFINE([S64BITS], [], [I guess a 64 bits machine])
dnl fi
dnl if test "$SIZEOF_LONG" = "4";
dnl then
dnl	AC_DEFINE([S32BITS], [], [I guess a 32 bits machine])
dnl fi

# Check MPI is present?
ACX_MPI([],[])

# Check VTK is present
ACX_OPTIONS_VTK()
ACX_PATH_VTK([],[],[])


# Check for the maths library
AC_CHECK_LIB([m], [hypot], [MATH_LIBS=-lm AC_SUBST(MATH_LIBS)], AC_MSG_WARN([*** libm is required]))

# Check for some header files
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h unistd.h sched.h])

# Alpha Linux specific for cpulim
AC_CHECK_HEADER([asm/param.h],
[AC_DEFINE([HAVE_ASM_PARAM_H], [1], [Define to 1 if you have asm/param.h])],
[AC_MSG_WARN([Cpulim for hegrid requires Alpha Linux])])
AM_CONDITIONAL([WANT_CPULIM], [test $HAVE_ASM_PARAM_H])

# Linux specific for pim2
AC_CHECK_FUNC([set_affinity],
[AC_DEFINE([HAVE_SET_AFFINITY], [1], [Define to 1 if you have set_affinity in sched.h (ie Linux)])],
[AC_MSG_WARN([pim2 for hemap requires Linux 64 bits])])
AM_CONDITIONAL([WANT_PIM2], [test $HAVE_SET_AFFINITY])


# Check for typedefs, structures, and compiler characteristics
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T

# Check for library functions
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([bzero gethostbyaddr gethostbyname gethostname inet_ntoa memset socket sqrt strtol])



dnl AC_CONFIG_SRCDIR(build-aux)
AC_CONFIG_HEADERS([config.h])

AC_CONFIG_FILES([
Makefile 
hebench/Makefile
doc/Makefile
hebench/bandwidth/Makefile 
hebench/hebench/Makefile
hebench/hebench/mpi/Makefile
hebench/hebench/seq/Makefile 
hebench/hebench/args/Makefile 
hegrid/Makefile
hegrid/cpulim/Makefile
hemap/Makefile
hemap/client/Makefile
hemap/daemons/Makefile
hemap/daemons/wrekaMPI/Makefile
hemap/daemons/pim2/Makefile
hemap/graphics/Makefile
])

AC_OUTPUT


